package com.graduate.daydayup.activity

import android.os.Bundle
import com.blankj.utilcode.util.SPUtils
import com.blankj.utilcode.util.SpanUtils
import com.blankj.utilcode.util.ToastUtils
import com.graduate.daydayup.App
import com.graduate.daydayup.R
import com.graduate.daydayup.base.BaseActivity
import com.graduate.daydayup.room.Account
import com.graduate.daydayup.room.MyRoomDataBase
import kotlinx.android.synthetic.main.activity_edit.*
import kotlinx.android.synthetic.main.activity_register.*
import kotlinx.android.synthetic.main.activity_register.btn_cancel
import kotlinx.android.synthetic.main.activity_register.btn_register
import kotlinx.android.synthetic.main.activity_register.et_account
import kotlinx.android.synthetic.main.activity_register.et_pass

class EditActivity :BaseActivity() {
    override fun setTitle()=""

    override fun getLayout()= R.layout.activity_edit

    override fun setTextRight()=""

    override fun setImgRightListener() {

    }

    override fun isAddToolbar()=false

    override fun initViewIds() {
        btn_edit.setOnClickListener {
            var allByAccount = MyRoomDataBase.getInstance(this).accountDao().getAllByAccount(SPUtils.getInstance().getString("account"))
            if (et_pass.text.toString().isEmpty()){
                ToastUtils.showShort("密码为空")
            }else{
                allByAccount.pass=et_pass.text.toString()
                MyRoomDataBase.getInstance(this).accountDao().updateAccount(  allByAccount)
                ToastUtils.showShort("修改成功")
                finish()
            }
        }
        btn_cancel.setOnClickListener {
            finish()
        }
    }

    override fun initView() {

    }

    override fun initData(savedInstanceState: Bundle?) {

    }
}